package com.mydemo.design_pattern.action_type.memento_pattern;

/**
 * <p></p >
 *
 * @author liming1
 * @version $Id: TestDemo, v1.0 2019-09-23 14:34 liming1 Exp $
 */
public class TestDemo {
    public static void main(String[] args) {
        Originator originator = new Originator();
        CareTaker careTaker = new CareTaker();
        originator.setState("state #1");
        originator.setState("state #2");
        careTaker.add(originator.saveStateToMemento());
        originator.setState("state #3");
        careTaker.add(originator.saveStateToMemento());
        originator.setState("state #4");

        System.out.println("current state :"  + originator.getState());
        originator.getStateFromMemento(careTaker.get(0));
        System.out.println("1 state :"  + originator.getState());
        originator.getStateFromMemento(careTaker.get(1));
        System.out.println("2 state :"  + originator.getState());
    }
}
